#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

int countWords(const char *str)
{
    if (!str) return 0;
    const char *s = str;
    int count = 0;
    while (*str) {
        while(*str && *str == ' ') str++;
        count++;
        while(*str && *str != ' ') str++;

    }
    return count;
}


int main(int argc, char **argv)
{

    cout << "-----------------Test 1--------------------" << endl;
    string str("hangyu is engineer");
    cout << countWords(str.c_str()) << endl;

    cout << "-----------------Test 2--------------------" << endl;
    cout << countWords("   hangyu is   engineer  ") << endl;

    cout << countWords(NULL) << endl;

    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
